/************************************************************************/
// Copyright (C) 2016, han_gangbiao. All rights reserved.
// Use of this source code is governed by a GPL-v2 license that can be found in the License file.
// 
// [Time]:      2016-3-20 16:44:19
// [Author]:    han_gangbiao [http://my.oschina.net/jackhen]
// [Info]:      
/************************************************************************/

#include "RPCServer.h"

CRPCServer::CRPCServer( CRpcServerMgr* pMgr )
    :CRpcServerBase(pMgr)
{
    
}

int CRPCServer::on_invoke( SOCK_FD fd, smart::ref_ptr<NetBinaryPdu> pdu )
{
    /*printf("on_invoke: %s\n", pdu->getBody());
    NetBinaryPduRequest* request = dynamic_cast<NetBinaryPduRequest*>(pdu.getPointer());
    if(request == NULL)
    {
        pdu->setFlag(NET_PDU_RESPONSE);
        pdu->setBody("invalid request");
        invoke(fd, pdu.getPointer());
        return 0;
    }
    smart::ref_ptr<NetBinaryPduResponse> response = request->createResponse();
    response->setBody("OK!");

    invoke(fd, response.getPointer());*/
    
    //>test latency
    invoke(fd, pdu.getPointer());
    return 0;
}

int CRPCServer::on_rpc_close( SOCK_FD fd, int errcode )
{
    printf("on_rpc_close fd=[%d], errcode=[%d]\n", fd, errcode);
    return 0;
}
